home *** CD-ROM | disk | FTP | other *** search
- /***************************************************************************
- *
- * Copyright (c) 1990-1993 The Santa Cruz Operation, Inc.
- *
- * All rights reserved. No part of this program or publication may be
- * reproduced, transmitted, transcribed, stored in a retrieval system,
- * or translated into any language or computer language, in any form or
- * by any means, electronic, mechanical, magnetic, optical, chemical,
- * biological, or otherwise, without the prior written permission of:
- *
- * The Santa Cruz Operation , Inc. (408) 425-7222
- * 400 Encinal St., Santa Cruz, California 95060 USA
- *
- **************************************************************************/
-
- /*
- * SCCS Stuff
- *
- * @(#) buttons.c 12.1 95/05/09 SCOINC
- *
- * S003, 15-Sep-93, rickra
- * ifdef out point_to_MyButton. This is no longer used since all
- * buttons have now been replaced by motif buttons....
- *
- * S002, 51-May-93, rickra
- * Removed some dead code, PS button code. It has been replaced by
- * motif buttons now... Also, pass in current_server, rather that
- * using a global variable.
- * S001, 01-Jan-93, rickra
- * Added support for seperate windows, support for buttons in
- * PSMEM.
- * S000, 30-Sep-92, rickra
- * Added copyright and modification history
- */
-
- /*+-------------------------------------------------------------------------
- buttons.c - XSW button and status message handler
- wht@n4hgf.Mt-Park.GA.US
-
- Defined functions:
- disp_msg(pixel,msg)
- draw_PS_MyButton(num,pixel,init_struct)
- draw_MyButton(num,pixel,init_struct)
- place_MyButtons_all_off()
- point_to_MyButton(x,y)
-
- --------------------------------------------------------------------------*/
- /*+:EDITS:*/
- /*:09-25-1990-05:11-wht@n4hgf-release heh-heh x0.22 preliminary */
- /*:09-20-1990-00:09-wht@n4hgf-scales, sysinfo/minfo, bootinfo working */
- /*:09-15-1990-14:47-wht-creation */
-
- #include <X11/Xlib.h>
- #include <X11/Xutil.h>
- #include <X11/Intrinsic.h>
- #include <X11/Shell.h>
- #include <X11/StringDefs.h>
- #include <Xm/Xm.h>
- #include <Xm/MainW.h>
- #include <Xm/DrawingA.h>
-
- #include "include/unixincs.h"
-
- #include "include/buttons.h"
- #include "include/resources.h"
- #include "include/xsw.h"
-
-
- int MyButton_TLX = 1;
- int MyButton_TLY = 1;
-
- int MyButtons_next_tlx = 0;
- int DispMsg_tlx = 70;
-
- extern struct NetworkXswStruct *current_server;
-
- extern MyResources res;
-
-
- /*+-------------------------------------------------------------------------
- draw_PS_MyButton(num,ps_mode,pixel,pixel2,
- init_struct,X_position,Y_position)
- --------------------------------------------------------------------------*/
- void
- draw_PS_MyButton (window, display, gc, DrawAreaXYWH,
- num, ps_mode, pixel, pixel2,
- init_struct, X_position, Y_position)
- Window window;
- Display *display;
- GC gc;
- XWindowAttributes DrawAreaXYWH;
- int num;
- int ps_mode;
- unsigned long pixel;
- unsigned long pixel2;
- int init_struct;
- int X_position;
- int Y_position;
- {
- MyButton *butt;
- int line_style = LineSolid;
- int cap_style = CapButt;
- int join_style = JoinMiter;
- int x, y, w, h;
- #define BOXTHICKNESS 3 /* odd */
-
- if (ps_mode == BUTTON_ps_cpu)
- butt = ¤t_server -> PS_MyButton_decl[num];
- else if (ps_mode == BUTTON_ps_io)
- butt = ¤t_server -> IO_PS_MyButton_decl[num];
- else if (ps_mode == BUTTON_ps_mem)
- butt = ¤t_server -> MEM_PS_MyButton_decl[num];
-
- if (init_struct)
- {
-
- butt -> tlx = X_position;
- butt -> tly = Y_position;
- butt -> width = (strlen (butt -> label) * FWIDTH) + (2 * FGAP) +
- BOXTHICKNESS;
-
- butt -> height = FASCENT;
-
- /* FHEIGHT + (2 * FGAP) + BOXTHICKNESS */ ;
- butt -> brx = butt -> tlx + butt -> width;
- butt -> bry = butt -> tly + butt -> height;
- }
-
- /* draw the box */
- XSetForeground (display, gc, /* foreground */ pixel);
- XSetLineAttributes (display, gc, BOXTHICKNESS,
- line_style, cap_style, join_style);
- XDrawRectangle (display, window, gc,
- x = butt -> tlx + (BOXTHICKNESS / 2),
- y = butt -> tly,
- w = butt -> width,
- h = butt -> height);
-
- /* the "background" color */
- XSetForeground (display, gc, pixel2);
- XFillRectangle (display, window, gc, x, y, w, h);
-
- if (init_struct)
- {
- XPoint rpoints[5];
-
- if (butt -> region)
- XDestroyRegion (butt -> region);
- rpoints[0].x = x;
- rpoints[0].y = y;
- rpoints[1].x = x + w;
- rpoints[1].y = y;
- rpoints[2].x = x + w;
- rpoints[2].y = y + h;
- rpoints[3].x = x;
- rpoints[3].y = y + h;
- rpoints[4].x = x;
- rpoints[4].y = y;
- butt -> region = XPolygonRegion (rpoints, 5, EvenOddRule);
- }
-
- /* draw the label */
- XSetForeground (display, gc, pixel);
- XDrawString (display, window, gc,
- butt -> tlx + BOXTHICKNESS + FGAP,
- butt -> tly + BOXTHICKNESS + (FASCENT / 2) + FGAP /* + FASCENT */ ,
- butt -> label, strlen (butt -> label));
-
- } /* end of draw_PS_MyButton */
-
- #ifdef OLDWAY
- /*+-------------------------------------------------------------------------
- point_to_MyButton(x,y)
-
- returns button number point is in, else -1
- --------------------------------------------------------------------------*/
- int
- point_to_MyButton (window, display, x, y)
- Window window;
- Display *display;
- int x;
- int y;
- {
- int ibutt;
-
- Window root_window;
- Window child_return;
- int root_x_return, root_y_return;
- int win_x_return, win_y_return;
- unsigned int mask_return;
-
-
- if (current_server -> COMMAND_LIST[BUTTON_ps_cpu].on == 1)
- {
- if (current_server -> SEPERATE_WINDOWS_LIST[BUTTON_ps_cpu].window == window)
- {
- for (ibutt = 0; ibutt < PS_MyButton_QUAN; ibutt++)
- {
- if (XPointInRegion (current_server -> PS_MyButton_decl[ibutt].region, x, y))
- return (25 + ibutt);
- }
- }
- }
-
- if (current_server -> COMMAND_LIST[BUTTON_ps_io].on == 1)
- {
- if (current_server -> SEPERATE_WINDOWS_LIST[BUTTON_ps_io].window == window)
- {
- for (ibutt = 0; ibutt < IO_PS_MyButton_QUAN; ibutt++)
- {
- if (XPointInRegion (current_server -> IO_PS_MyButton_decl[ibutt].region, x, y))
- return (40 + ibutt);
- }
-
- }
-
- }
-
- if (current_server -> COMMAND_LIST[BUTTON_ps_mem].on == 1)
- {
- if (current_server -> SEPERATE_WINDOWS_LIST[BUTTON_ps_mem].window == window)
- {
- for (ibutt = 0; ibutt < MEM_PS_MyButton_QUAN; ibutt++)
- {
- if (XPointInRegion (current_server -> MEM_PS_MyButton_decl[ibutt].region, x, y))
- return (60 + ibutt);
- }
-
- }
-
- }
-
-
- return (-1);
- } /* end of point_to_MyButton */
-
- #endif
-
- unsigned long last_DispMsg_pixel = -1;
- char last_DispMsg_msg[80] =
- {0x01, 0x00};
-
- /*+-------------------------------------------------------------------------
- disp_msg(pixel,msg)
-
- This is put in here because the message area is on the second
- "line" of the window from the right of the buttons to the right hand
- side of the window
- --------------------------------------------------------------------------*/
- void
- disp_msg (pixel, msg)
- unsigned long pixel;
- char *msg;
- {
- register int y = Disp_msg_TLY;
-
- if (!window)
- return;
- /*
- if((pixel == last_DispMsg_pixel) && !strcmp(msg,last_DispMsg_msg))
- return;
- */
- XClearArea (display, window,
- 0, y, DrawAreaXYWH.width - (FWIDTH * 10), FHEIGHT, 0);
- XSetForeground (display, gc, pixel);
- XDrawString (display, window, gc,
- 0, y + FASCENT, msg, strlen (msg));
- last_DispMsg_pixel = pixel;
- strcpy (last_DispMsg_msg, msg);
- } /* end of disp_msg */
-
- /*+-------------------------------------------------------------------------
- invalidate_last_DispMsg()
- --------------------------------------------------------------------------*/
- void
- invalidate_last_DispMsg ()
- {
- last_DispMsg_pixel = -1;
- last_DispMsg_msg[0] = 0x01;
- last_DispMsg_msg[1] = 0x00;
- } /* end of invalidate_last_DispMsg */
-
- /* vi: set tabstop=4 shiftwidth=4: */
- /* end of buttons.c */
-